package com.z001.snack.common.module.support.codegenerator.domain.model;

import com.z001.snack.common.module.support.codegenerator.constant.CodeDeleteEnum;
import com.z001.snack.common.module.support.codegenerator.constant.CodeGeneratorPageTypeEnum;

import java.util.HashMap;

/**
 * 初始化所有表 相关参数
 * @author szy
 * @Date 2023/7/11 14:25
 */
public  class InitCode {

    //########################################## 后端相关 ##########################################

    /**
     * 数据库前缀
     */
    public static final String DB_PREFIX = "t_";
    /**
     * java 包名地址
     */
    public static final String JAVA_PACKAGE_NAME = "com.z001.snack.admin.module.business.";
    /**
     * 后台 注释作者
     */
    public static final String BACKEND_AUTHOR = "szy";
    /**
     * 前台 注释作者
     */
    public static final String FRONT_AUTHOR = "szy";
    /**
     * java类型
     */
    public static HashMap<String,String> javaTypeMap;

    /**
     * 删除类型
     */
    public static final String DELETE_ENUM = CodeDeleteEnum.SINGLE_AND_BATCH.getValue().toString();

    /**
     * 是否为物理删除
     */
    public static boolean IS_PHYSICALLY_DELETED = true;

    /**
     * Entity 父类包地址
     */
    public static final String BASE_ENTITY_PACKAGE = "import com.z001.snack.common.common.domain.BaseEntity;";

    /**
     * Entity 父类类名称
     */
    public static final String BASE_ENTITY_NAME = "BaseEntity";

    /**
     * 注解 @API 引入包
     */
    public static final String API_PACKAGE = "import com.z001.snack.common.module.support.operatelog.annoation.Api;";

    /**
     * 注解 @ApiOperation 引入包
     */
    public static final String API_OPERATION_PACKAGE = "import com.z001.snack.common.module.support.operatelog.annoation.ApiOperation;";



    //########################################## 前端相关 ##########################################
    /**
     * 每行字段数量
     */
    public static final Integer COUNT_PER_LINE = 1;

    /**
     * 页面类型
     */
    public static final String PAGE_TYPE = CodeGeneratorPageTypeEnum.MODAL.getValue().toString();

    /**
     * 页面宽度
     */
    public static final String WIDTH = "500ox";
    /**
     * js类型
     */
    public static HashMap<String,String> jsTypeMap;

    /**
     * 前端组件
     */
    public static HashMap<String,String> frontComponentMap;



    //########################################## 静态代码块 ##########################################

    /**
     * DB 和 java 以及前端 数据类型转换
     */
    static {
        //java 类型
        HashMap<String,String> javaMap = new HashMap<>();
        javaMap.put("int", "Integer");
        javaMap.put("tinyint", "Integer");
        javaMap.put("smallint", "Integer");
        javaMap.put("integer", "Integer");
        javaMap.put("year", "Integer");
        javaMap.put("bigint", "Long");
        javaMap.put("float", "BigDecimal");
        javaMap.put("double", "BigDecimal");
        javaMap.put("decimal", "BigDecimal");
        javaMap.put("char", "String");
        javaMap.put("varchar", "String");
        javaMap.put("tinytext", "String");
        javaMap.put("text", "String");
        javaMap.put("longtext", "String");
        javaMap.put("blob", "String");
        javaMap.put("date", "LocalDate");
        javaMap.put("datetime", "LocalDateTime");
        javaMap.put("bit","Boolean");
        javaTypeMap = javaMap;

        //js 类型
        HashMap<String,String> jsMap = new HashMap<>();
        jsMap.put("int", "Number");
        jsMap.put("tinyint", "Number");
        jsMap.put("smallint", "Number");
        jsMap.put("integer", "Number");
        jsMap.put("year", "Number");
        jsMap.put("bigint", "Number");
        jsMap.put("float", "Number");
        jsMap.put("double", "Number");
        jsMap.put("decimal", "Number");
        jsMap.put("char", "String");
        jsMap.put("varchar", "String");
        jsMap.put("tinytext", "String");
        jsMap.put("text", "String");
        jsMap.put("longtext", "String");
        jsMap.put("blob", "String");
        jsMap.put("date", "Date");
        jsMap.put("datetime", "Date");
        jsMap.put("bit", "Boolean");
        jsTypeMap = jsMap;

        //前端组件 类型
        HashMap<String,String> componentMap = new HashMap<>();
        componentMap.put("int", "InputNumber");
        componentMap.put("tinyint", "BooleanSelect");
        componentMap.put("smallint", "InputNumber");
        componentMap.put("integer", "InputNumber");
        componentMap.put("year", "Date");
        componentMap.put("bigint", "InputNumber");
        componentMap.put("float", "InputNumber");
        componentMap.put("double", "InputNumber");
        componentMap.put("decimal", "InputNumber");
        componentMap.put("char", "Input");
        componentMap.put("varchar", "Input");
        componentMap.put("tinytext", "Input");
        componentMap.put("text", "Textarea");
        componentMap.put("longtext", "Textarea");
        componentMap.put("blob", "Upload");
        componentMap.put("date", "Date");
        componentMap.put("datetime", "DateTime");
        componentMap.put("bit", "BooleanSelect");

        frontComponentMap = componentMap;

    }

}
